package test;

//所有子集的异或总和在求和：https://leetcode.cn/problems/sum-of-all-subset-xor-totals/description/
public class SubsetXORSum1 {
	public static int sum;
    public static boolean[] check;
    public static void dfs(int[] nums,int pos,int path){
        if(pos==nums.length){
        	//sum+=path; 错误
            return ;
        }
        for(int i=pos;i<nums.length;i++){
            if(check[i]==false){
                check[i]=true;
                sum+=path^nums[i];
                //sum+=path;  错误
                dfs(nums,i+1,path^nums[i]);
                check[i]=false;
            }
        }
    }
    public static int subsetXORSum(int[] nums) {
        sum=0;
        check=new boolean[nums.length];
        dfs(nums,0,0);
        reåturn sum;
    }
    public static void main(String[] args) {
		int[] arr=new int[] {1,3};
		subsetXORSum(arr);
	}

}
